from fastapi import FastAPI
from pydantic import BaseModel
import uvicorn

# 创建app对象
app = FastAPI()


# 创建Book数据模型
class Book(BaseModel):
    title: str
    author: str
    price: float


# 定义路由函数
@app.post("/books/")
async def book_data(book: Book):
    return book


if __name__ == "__main__":
    uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)
